const express = require('express')
//引入外部路由
const addAdminRoute = require("./routes/addAdmin");
const adminListRoute = require("./routes/adminList");
const deleteAdminRoute = require('./routes/deleteAdmin')
const loginRoute = require("./routes/login")
const isLoginRoute = require('./routes/isLogin')
const logout = require("./routes/logout")
const path = require("path")
const addAdv = require('./routes/addAdv')
const advList = require('./routes/advList')
const deleteAdv = require('./routes/deleteAdv')
const getUpdateData = require('./routes/getUpdateData')
const update = require('./routes/updateAdv')
require('./db/db')

const app = express()
app.use(express.urlencoded())
app.use(express.json())
app.use('/upload',express.static(path.resolve(__dirname,'./upload')))
//使用路由
app.use(addAdminRoute)
app.use(adminListRoute)
app.use(deleteAdminRoute)
app.use(loginRoute);
app.use(isLoginRoute)
app.use(logout)
app.use(addAdv)
app.use(advList)
app.use(deleteAdv)
app.use(getUpdateData)
app.use(update)
app.listen('9000', () => {
    console.log('服务器启动成功');
})